package com.zeta.eduservice.controller.question;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.zeta.commonutils.R;
import com.zeta.eduservice.entity.vo.SubjectNestedVo;
import com.zeta.eduservice.service.EduSubjectService;

import io.swagger.annotations.ApiOperation;
@CrossOrigin
@RestController
@RequestMapping("/eduservice/subject")
public class EduSubjectController {
    @Autowired
     EduSubjectService subjectService;

    //添加课程分类
    //获取上传过来文件，把文件内容读取出来
    @PostMapping("/addSubject")
    public R addSubject(MultipartFile file) {
        //上传过来excel文件
        subjectService.saveSubject(file,subjectService);
    
        return R.ok();
    }

    @ApiOperation("获得树形课程")
    @GetMapping("/getAllSubject")
    public R getAllSubject() {
    	 List<SubjectNestedVo> subjectNestedVoList = subjectService.nestedList();
    	return R.ok().data("items",subjectNestedVoList);
    }
}



